var express = require('express');
var router = express.Router();

router.post('/list', function (req, res, next) {
  const { offset = 0, size = 10 } = req.body;
  const menus = [];

  for (let i = offset; i < offset + size; i++) {
    menus.push({
      id: i + 1,
      name: `菜单${i + 1}`,
      type: 'menu',
      url: `/menu/${i + 1}`,
      icon: `icon${i + 1}`,
      sort: i + 1,
      createAt: new Date().toISOString(),
      updateAt: new Date().toISOString(),
      children: [
        {
          id: (i + 1) * 10 + 1,
          name: `子菜单${(i + 1) * 10 + 1}`,
          type: 'submenu',
          url: `/submenu/${(i + 1) * 10 + 1}`,
          icon: `icon${(i + 1) * 10 + 1}`,
          sort: (i + 1) * 10 + 1,
          createAt: new Date().toISOString(),
          updateAt: new Date().toISOString(),
          parentId: i + 1,
          children: [
            {
              id: (i + 1) * 100 + 1,
              name: `按钮权限${(i + 1) * 100 + 1}`,
              type: 3,
              url: null,
              sort: null,
              createAt: new Date().toISOString(),
              updateAt: new Date().toISOString(),
              parentId: (i + 1) * 10 + 1,
              permission: 'system:user:delete',
            },
          ],
        },
      ],
    });
  }
  res.send({ code: 0, data: { list: menus, total: menus.length * 10 } });
});

module.exports = router;
